How to create your own plugin from this template

This folder contains a working example plugin for PCAutomation / Smap3D P&ID. Use it as a starting point for your own plugin by following the steps below in order.

To make PCAutomation / Smap3D P&ID aware of your plugin, a few "identity" values need to be set up correctly — that's what most of this guide is about.

What you need

Overview of the steps

  1. Try the template as-is first, before changing anything.
  2. Give your plugin its own unique ID (a "GUID").
  3. Update the .MIF file to match, and give your plugin a name.
  4. Write your plugin's code.
  5. Build the project.
  6. Register the plugin with Windows (one-time step).
  7. Install the plugin inside PCAutomation / Smap3D P&ID.

Steps 1, 2 and 5 are things you only do once per plugin. After that, you can rebuild and test as often as you like without repeating them (unless noted otherwise below).


Step 0 — Try the template as-is first

Before you change anything, it's worth going through Steps 4-6 below once with the template exactly as you received it (it's a working test plugin on its own — it just shows a small demo window with a list). That way, if something doesn't work later while you're building your own plugin, you already know your machine, Visual Studio, and PCAutomation / Smap3D P&ID setup are all fine, and the problem is something in your own changes rather than the environment.

So: skip ahead to Step 4 (Build), then Step 5 (Register), then Step 6 (Install), and confirm the demo plugin shows up under Tools and opens a small window when clicked. Once that works, come back here and continue with Step 1 to turn it into your own plugin.


Step 1 — Give your plugin its own unique ID (GUID)

Windows identifies COM components (like this plugin) using a GUID — a long, unique code that looks like {8FBDD806-182B-4D5C-82F3-491AA7057001}. Think of it as a serial number: if two different plugins accidentally use the same GUID, Windows won't be able to tell them apart, and things will behave unpredictably. That's why the very first thing you must do is generate a new, unique GUID for your plugin.

Open PCsTestPlugin.cs and look near the bottom of the file for this:

[Guid("8FBDD806-182B-4D5C-82F3-491AA7057001")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public sealed class PCsPlugin : IPCsPluginSimple

You need to replace 8FBDD806-182B-4D5C-82F3-491AA7057001 with a new GUID of your own.

How to generate a new GUID:

  1. Open PowerShell (click Start, type PowerShell, press Enter).
  2. Type this and press Enter:
    [guid]::NewGuid()
    
  3. Copy the value it prints out.
  4. Paste it into the [Guid("...")] line above, replacing the old value, keeping the surrounding quotes.

⚠️ Do not touch the other GUID in this file — the one on the IPCsPluginSimple interface (7020B4F9-25D5-47AF-BAAB-BFE710DD32AA). That one is fixed and owned by PCAutomation / Smap3D P&ID itself; it's how the program recognizes any plugin. Only the GUID on your PCsPlugin class (your plugin's own identity) should be changed.

Write your new GUID down somewhere — you'll need the exact same value again in Step 2.


Step 2 — Update the .MIF file

The .MIF file (PCsPluginTestDLL_Modal.MIF) is a small text file that tells PCAutomation / Smap3D P&ID about your plugin: what it's called, which menu it should appear in, and which GUID to activate when it's clicked.

Open it in Notepad and you'll see something like this:

[Modul]
Title=Test Modal Plugin

[Plugin]
Menu1=Tools
Name1=Test Modal Plugin
Cmd1={8FBDD806-182B-4D5C-82F3-491AA7057001}
Index1=200

Make these changes:

Field What to change it to
Title The name of your plugin, as you want it to appear in File → Modules.
Name1 The name of your plugin, as you want it to appear in the Tools menu. Can be the same as Title.
Cmd1 The exact same GUID you generated in Step 1, in curly braces {...}. This is what links the MIF file to your plugin's code.
Menu1 Which menu the plugin appears under (Tools is a safe default).
Index1 Sort order within that menu — any number works, lower numbers appear first.

Do not change the section headers [Modul] and [Plugin] — PCAutomation / Smap3D P&ID looks for those exact names (note it's [Modul], not the English "Module").

⚠️ Important — saving the file: the .MIF file must be saved as Unicode text, not plain ANSI/UTF-8 text. In Notepad: File → Save As, then set the Encoding dropdown (bottom right of the Save dialog) to Unicode, and save over the existing file. If you save it with the wrong encoding, your plugin will show up in the Modules list with its file path instead of its proper name (see Troubleshooting below).


Step 3 — Write your plugin's code

Still in PCsTestPlugin.cs, look at the Execute() method:

public bool Execute()
{
    form = new Form();
    form.Text = "Test custom window " + ...;

    ListView listView = new ListView();
    ...

    form.ShowDialog(new Win32Window(windowHandle));

    return true; // always return true - see note below
}

This method runs whenever a user clicks your plugin in the Tools menu. Replace the demo ListView/Form code with whatever your plugin should actually do. A few notes:


Step 4 — Build the project

  1. Open PCsPluginTestDLL_Modal.sln in Visual Studio.
  2. Make sure the build configuration is set to x86 (not "Any CPU" or "x64") — PCAutomation / Smap3D P&ID is a 32-bit program, so your plugin must be built as 32-bit too.
  3. Build the project (Build → Build Solution, or Ctrl+Shift+B).

The project is already set up to automatically copy the built files to C:\PCAutomation\ after every build. If PCAutomation / Smap3D P&ID is installed somewhere else on your machine, please change the destination path.


Step 5 — Register the plugin with Windows

Before Windows will let PCAutomation / Smap3D P&ID load your plugin, you need to tell Windows where to find it. This is a one-time step called COM registration, and only needs to be repeated if you later change your plugin's GUID or move its files to a different folder — a normal rebuild does not require re-registering.

  1. Double-click Register.bat (in the Source folder).
  2. Windows will ask for administrator permission — click Yes.
  3. A confirmation popup should appear saying the registration succeeded.

To remove the plugin later, use Unregister.bat the same way.

⚠️ If PCAutomation / Smap3D P&ID is installed somewhere other than C:\PCAutomation\, open Register.bat and Unregister.bat in a text editor first, and update the file path in each of them to match the folder your build output actually gets copied to (the same folder you set up in Step 4).


Step 6 — Install the plugin inside PCAutomation / Smap3D P&ID

  1. Open PCAutomation / Smap3D P&ID.
  2. Go to File → Modules.
  3. Find your plugin in the list (it will show the Title you set in the .MIF file).
  4. Select it and click Install.

Your plugin will now show up in the Tools menu. Click it to try it out.


Troubleshooting

Problem Likely cause
"Class not registered" error when clicking the plugin You skipped Step 5, or the GUID in PCsTestPlugin.cs doesn't match the one you registered. Rebuild, then run Register.bat again.
The Modules list shows a file path instead of your plugin's name The .MIF file wasn't saved as Unicode, or the [Modul] section header was changed/misspelled. Re-open it and re-save with the Unicode encoding as described in Step 2.
Plugin doesn't appear in File → Modules at all The .MIF file wasn't copied to PCAutomation / Smap3D P&ID's folder. Rebuild the project (Step 4) and check the file landed in the right place, or copy it there by hand.
Plugin installed, but doesn't show up in the Tools menu Make sure you clicked Install in File → Modules (not just selected it), then restart PCAutomation / Smap3D P&ID.
Nothing happens, or odd/unexpected behavior between two different plugins Double-check your class's GUID is actually unique — a common mistake is forgetting to change it after copying the template.

Making more than one plugin from this template?

If you're only building a single plugin, you don't need to rename anything — changing the GUID (Step 1) and the .MIF file (Step 2) is enough. But if you plan to build several different plugins from copies of this template, you should also rename the project so their built files don't overwrite each other. That means renaming, consistently, in all of these places:

If you're not comfortable making all of those changes consistently, it's simplest to just keep one plugin per copy of this template folder.